package com.rfid.manager;


import com.rfid.acs.AcsBookNet;
import com.rfid.acs.bean.BookBean;
import com.rfid.acs.net.IBookNet;
import com.rfid.acs.net.bean.ReaderInfoBean;
import com.rfid.acs.net.bean.RestoreBookBean;

import java.util.List;

import io.reactivex.Observable;

public enum BookManager {

    INSTANCE;

    private IBookNet mBookNet = new AcsBookNet();

    /**
     * 通过图书条码号从后台查询图书详细信息
     *
     * @param barcode 图书条码号
     * @return 图书bean
     */
    public Observable<BookBean> searchBookWithBarcode(String barcode) {
        return mBookNet.searchBookWithBarcode(barcode);
    }

    /**
     * 通过图书条码号借书
     *
     * @param barcode  图书条码号
     * @param readerNo 读者证号
     * @return 借书结果bean
     */
    public Observable<BookBean> borrowBook(String barcode, String readerNo, String password) {
        return mBookNet.borrowBook(barcode, readerNo, password);
    }

    /**
     * 通过图书条码号续借
     *
     * @param barcode  图书条码号
     * @param readerNo 读者证号
     * @return 续借结果bean
     */
    public Observable<BookBean> renewalBook(String barcode, String readerNo, String password) {
        return mBookNet.renewalBook(barcode, readerNo, password);
    }

    /**
     * 通过图书条码号还书
     *
     * @param barcode 图书条码号
     * @return 还书结果bean
     */
    public Observable<RestoreBookBean> restoreBook(String barcode) {
        return mBookNet.restoreBook(barcode);
    }

    /**
     * 通过读者证号查询读者信息
     *
     * @param readerNo 读者证号
     * @return 读者信息bean
     */
    public Observable<ReaderInfoBean> searchReaderInfo(String readerNo, String password) {
        return mBookNet.searchReaderInfo(readerNo, password);
    }

    public Observable<List<BookBean>> searchBooksWithBarcode(List<String> strings) {
        return mBookNet.searchBooksWithBarcode(strings);
    }

}
